Component({
    interval: null,
    initLocalTimestamp: 0,
    initCd: 0,
    options: {
        addGlobalClass: !0
    },
    properties: {
        desc: String,
        cd: {
            type: Number
        }
    },
    data: {
        showCd: -1
    },
    lifetimes: {
        detached: function() {
            this.stopTimer();
        }
    },
    detached: function() {
        this.stopTimer();
    },
    pageLifetimes: {
        show: function() {
            this.startTimer();
        },
        hide: function() {
            this.stopTimer();
        }
    },
    methods: {
        init: function() {
            this.stopTimer(), this.initCd = this.data.cd, this.initLocalTimestamp = new Date().getTime(), 
            this.updateCd(), this.startTimer();
        },
        startTimer: function() {
            var t = this;
            this.stopTimer(), this.interval = setInterval(function() {
                t.updateCd();
            }, 1e3);
        },
        stopTimer: function() {
            this.interval && (clearInterval(this.interval), this.interval = null);
        },
        updateCd: function() {
            var t = (new Date().getTime() - this.initLocalTimestamp) / 1e3, i = this.initCd - t.toFixed(0);
            this.setData({
                showCd: i
            }), i <= 0 && (this.stopTimer(), this.triggerEvent("cdOnEnd", {}));
        }
    }
});